//
//  ChooseView.m
//  TableViewDM
//
//  Created by mac on 2017/1/3.
//  Copyright © 2017年 G. All rights reserved.
//

#define SC_WIDTH [UIScreen mainScreen].bounds.size.width
#define SC_HEIGHT [UIScreen mainScreen].bounds.size.height
#define F10 10
#define TABHEIGHT 350

#import "ChooseView.h"
#import "TimeChooseCell.h"
#import "HcdDateTimePickerView.h"

@interface ChooseView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *baseTable;

@property (nonatomic, strong) NSMutableArray *dataArray;//选择时间数据源----

@property (nonatomic, assign) CGFloat allButtonHeight;//今天到今年占用高度

@property (nonatomic, strong) NSString *beginTime;//开始时间

@property (nonatomic, strong) NSString *endTime;//结束时间

@property (nonatomic, strong) NSString *monthBeginTime;//月指标开始时间

@property (nonatomic, strong) NSString *monthEndTime;//月指标结束时间

@property (nonatomic, strong) NSMutableArray *indexArray;//指标数据源-----

@property (nonatomic, assign) CGFloat indexButtonHeight;//指标数据源高度

@property (nonatomic, strong) NSString *yearStr;

@property (nonatomic, strong) HcdDateTimePickerView *dateTimePickerView;//日历选择器

@property (nonatomic, strong) NSMutableDictionary *oldDic;//存初始值

@property (nonatomic, assign) BOOL isfalg;//是否点击重置
@end

@implementation ChooseView

-(id)initWithFrame:(CGRect)frame
         timeArray:(NSMutableArray *)timeArray
         timeIndex:(NSInteger)timeIndex
         beginTime:(NSString *)beginTime
           endTime:(NSString *)endTime
        indexArray:(NSMutableArray *)indexArray
        indexIndex:(NSInteger)indexIndex
    mouthBeginTime:(NSString *)mouthBeginTime
      mouthEndTime:(NSString *)mouthEndTime
           yearStr:(NSString *)yearStr{
    self = [super initWithFrame:frame];
    if (self) {
        UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SC_WIDTH, TABHEIGHT + 45)];
        footView.backgroundColor = [UIColor whiteColor];
        [self addSubview:footView];
        
        _baseTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SC_WIDTH, TABHEIGHT) style:UITableViewStylePlain];
        _baseTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        _baseTable.delegate = self;
        _baseTable.dataSource = self;
        [footView addSubview:_baseTable];
        
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, TABHEIGHT, SC_WIDTH, 45)];
        CGFloat resetButtonWidth = (SC_WIDTH - 30)/2;
        UIButton *resetButton = [UIButton buttonWithType:UIButtonTypeSystem];
        resetButton.frame = CGRectMake(10, 5, resetButtonWidth, 35);
        [resetButton setTitle:@"重置" forState:UIControlStateNormal];
        [resetButton setTitleColor:[UIColor colorFromHexCode:@"#C0C0C0"] forState:UIControlStateNormal];
        resetButton.titleLabel.font = [UIFont systemFontOfSize:15];
        [resetButton.layer setBorderColor:[UIColor colorFromHexCode:@"#cccccc"].CGColor];
        [resetButton.layer setBorderWidth:0.5];
        resetButton.layer.cornerRadius = 3.0;
        [resetButton.layer setMasksToBounds:YES];
        [resetButton addTarget:self action:@selector(resetButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:resetButton];
        
        UIButton *sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
        sureButton.backgroundColor = [UIColor colorFromHexCode:@"#ff6b09"];
        sureButton.frame = CGRectMake(20 + resetButtonWidth, 5, resetButtonWidth, 35);
        [sureButton setTitle:@"确定" forState:UIControlStateNormal];
        [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureButton.titleLabel.font = [UIFont systemFontOfSize:15];
        [sureButton.layer setBorderColor:[UIColor colorFromHexCode:@"#cccccc"].CGColor];
        [sureButton.layer setBorderWidth:0.5];
        sureButton.layer.cornerRadius = 3.0;
        [sureButton.layer setMasksToBounds:YES];
        [sureButton addTarget:self action:@selector(sureButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:sureButton];
        view.backgroundColor = [UIColor colorFromHexCode:@"#f7f7f7"];
        [footView addSubview:view];
        [self addSubview:_baseTable];
        
//        _oldDic = [[NSMutableDictionary alloc] init];
//        [_oldDic setObject:[NSNumber numberWithInteger:timeIndex] forKey:@"timeIndex"];
//        [_oldDic setObject:beginTime forKey:@"beginTime"];
//        [_oldDic setObject:endTime forKey:@"endTime"];
//        [_oldDic setObject:[NSNumber numberWithInteger:indexIndex] forKey:@"indexIndex"];
//        [_oldDic setObject:mouthBeginTime forKey:@"mouthBeginTime"];
//        [_oldDic setObject:mouthEndTime forKey:@"mouthEndTime"];
//        [_oldDic setObject:yearStr forKey:@"yearStr"];
        
        _dataArray = timeArray;
        _indexArray = indexArray;
        _beginTime = beginTime;
        _endTime = endTime;
        _monthBeginTime = mouthBeginTime;
        _monthEndTime = mouthEndTime;
        _yearStr = yearStr;
        //计算出选择时间button的高度
        CGFloat yu = _dataArray.count%4;
        CGFloat chu = _dataArray.count/4;
        if (_dataArray.count != 0) {
            _allButtonHeight = chu*30 + chu *10;
            if (yu != 0) {
                _allButtonHeight = (chu + 1)*30 + (chu + 1)*10;
            }
        }
        //计算出选择指标button的高度
        CGFloat indexYu = _indexArray.count%4;
        CGFloat indexChu = _indexArray.count/4;
        if (_indexArray.count != 0) {
            _indexButtonHeight = indexChu*30 + indexChu*10;
            if (indexYu != 0) {
                _indexButtonHeight = (indexChu + 1)*30 + (indexChu + 1)*10;
            }
        }
        _indexIndex = indexIndex;//初始化传进来的时间按钮下标
        _timeIndex = timeIndex;//初次传进来的月指标按钮下标
        //默认当前年时间
//        NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; //初始化格式器。
//        [formatter setDateFormat:@"YYYY"];//定义c为这种格式 YYYY-MM-dd hh:mm:ss 。
//        NSString *currentTime = [formatter stringFromDate:[NSDate date]];
//        _yearStr = currentTime;
        
        UIView *toumingView = [[UIView alloc] initWithFrame:CGRectMake(0, TABHEIGHT + 40, SC_WIDTH, SC_HEIGHT - TABHEIGHT - 40)];
        [self addSubview:toumingView];
        self.backgroundColor  = [UIColor grayColor];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeHCD)];
        [toumingView addGestureRecognizer:tap];
    }
    
    return self;
}

#pragma mark - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        return 30 + _allButtonHeight + 10 + 30;
    }
    if (indexPath.row == 1) {
         return 30 + _indexButtonHeight + 10 + 30;
    }
    return 80;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"cellID";
    TimeChooseCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"TimeChooseCell" owner:self options:nil] lastObject];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row == 0 || indexPath.row == 1) {
    CGFloat buttonWidth = (SC_WIDTH - 50)/4;
        //成绩或者月指标
        UILabel *shijianLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
        if (indexPath.row == 0) {
           shijianLabel.text = @"成绩";
            
        }else{
            shijianLabel.text = @"月指标";
        }
        
        shijianLabel.font = [UIFont systemFontOfSize:15];
        [cell addSubview:shijianLabel];
        NSMutableArray *arr = [[NSMutableArray alloc] init];
        //0行和1行时 取不同的高和数据源
        CGFloat butHeight;
        if (indexPath.row == 0) {
            arr = _dataArray;
            butHeight = _allButtonHeight;
        }else{
            arr = _indexArray;
            butHeight = _indexButtonHeight;
        }
        // 选择时间
        for (int i = 0; i <arr.count; i++) {
            CGFloat yu = i%4;
            CGFloat chu = i/4;
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake((yu + 1)*10 + yu*buttonWidth, 30 + chu*30 + (chu + 1) *10, buttonWidth, 30);
            [button setTitle:arr[i] forState:UIControlStateNormal];
            [button setTitleColor:[UIColor colorFromHexCode:@"#3D3D3D"] forState:UIControlStateNormal];
            button.titleLabel.font = [UIFont systemFontOfSize:15];
            [button.layer setBorderColor:[UIColor colorFromHexCode:@"#BFBFBF"].CGColor];
            [button.layer setBorderWidth:0.5];
            button.layer.cornerRadius = 3.0;
            [button.layer setMasksToBounds:YES];
            [cell addSubview:button];
            [button addTarget:self action:@selector(allBUttonAction:) forControlEvents:UIControlEventTouchUpInside];
            //不同时取不同的tag值和选中效果
            if (indexPath.row == 0) {
                button.tag = 100 + i;
                if (_timeIndex == i) {
                    [button setTitleColor:[UIColor colorFromHexCode:@"#FF6B09"] forState:UIControlStateNormal];
                    button.backgroundColor = [UIColor colorFromHexCode:@"#FFE0CB"];
                    [button.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];

                }
            }else{
                button.tag = 200 + i;
                if (_indexIndex == i) {
                    [button setTitleColor:[UIColor colorFromHexCode:@"#FF6B09"] forState:UIControlStateNormal];
                    button.backgroundColor = [UIColor colorFromHexCode:@"#FFE0CB"];
                    [button.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];
                }
            }
           
        }
        // 起始时间
        CGFloat calendarBTWidth = (SC_WIDTH - 40)/2;
        UIButton *beginButton = [UIButton buttonWithType:UIButtonTypeCustom];
        beginButton.frame = CGRectMake(10, butHeight + 30 + 10 , calendarBTWidth, 30);
        beginButton.backgroundColor = [UIColor whiteColor];
        [beginButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [beginButton.layer setBorderColor:[UIColor colorFromHexCode:@"#BFBFBF"].CGColor];
        [beginButton.layer setBorderWidth:0.5];
        beginButton.layer.cornerRadius = 3.0;
        [beginButton.layer setMasksToBounds:YES];
        beginButton.titleLabel.font = [UIFont systemFontOfSize:15];
        //0行和1行时不同的时间
        if (indexPath.row == 0) {
            beginButton.tag = 1000;
            if (_beginTime == nil) {
                [beginButton setTitle:@"(起始时间)" forState:UIControlStateNormal];
            }else{
                //成绩开始时间
                NSArray *cjArr1 = [_beginTime componentsSeparatedByString:@"-"];
                //月份
                NSString *str = nil;
                if ([cjArr1[1] integerValue] < 10) {
                    str = [NSString stringWithFormat:@"0%@",cjArr1[1]];
                }else {
                    str = [NSString stringWithFormat:@"%@",cjArr1[1]];
                }
                //日
                NSString *str1 = nil;
                if ([cjArr1[2] integerValue] < 10) {
                    str1 = [NSString stringWithFormat:@"0%@",cjArr1[2]];
                }else {
                    str1 = [NSString stringWithFormat:@"%@",cjArr1[2]];
                }
                NSString *sjTimer = [NSString stringWithFormat:@"%@-%@-%@",cjArr1[0],str,str1];
                [beginButton setTitle:sjTimer forState:UIControlStateNormal];
                beginButton.backgroundColor = [UIColor colorFromHexCode:@"#FFE0CD"];
                [beginButton setTitleColor:[UIColor colorFromHexCode:@"#FF6B09"] forState:UIControlStateNormal];
                [beginButton.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];
            }
        }else{
             beginButton.tag = 2000;
            if (_monthBeginTime == nil) {
                [beginButton setTitle:@"(起始时间)" forState:UIControlStateNormal];
            }else{
                //月指标开始时间
                NSArray *cjArr1 = [_monthBeginTime componentsSeparatedByString:@"-"];
                //月份
                NSString *str = nil;
                if ([cjArr1[1] integerValue] < 10) {
                    str = [NSString stringWithFormat:@"0%@",cjArr1[1]];
                }else {
                    str = [NSString stringWithFormat:@"%@",cjArr1[1]];
                }
                NSString *yzbTimer = [NSString stringWithFormat:@"%@-%@",cjArr1[0],str];
                [beginButton setTitle:yzbTimer forState:UIControlStateNormal];
                beginButton.backgroundColor = [UIColor colorFromHexCode:@"#FFE0CB"];
                [beginButton setTitleColor:[UIColor colorFromHexCode:@"#FF6B09"] forState:UIControlStateNormal];
                [beginButton.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];
            }
        }
        [cell addSubview:beginButton];
        [beginButton addTarget:self action:@selector(beginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(10 + calendarBTWidth + 5, butHeight + 30 + 14.5 + 10, 10, 1)];
        lab.backgroundColor = [UIColor blackColor];
        [cell addSubview:lab];
        // 结束时间
        UIButton *endButton = [UIButton buttonWithType:UIButtonTypeCustom];
        endButton.frame = CGRectMake(10 + calendarBTWidth + 20, butHeight + 30 + 10, calendarBTWidth, 30);
        endButton.backgroundColor = [UIColor whiteColor];
        [endButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [endButton.layer setBorderColor:[UIColor colorFromHexCode:@"#BFBFBF"].CGColor];
        [endButton.layer setBorderWidth:0.5];
        endButton.layer.cornerRadius = 3.0;
        [endButton.layer setMasksToBounds:YES];
        endButton.titleLabel.font = [UIFont systemFontOfSize:15];
        if (indexPath.row == 0) {
             endButton.tag = 1001;
            if (_endTime == nil) {
                [endButton setTitle:@"(结束时间)" forState:UIControlStateNormal];
            }else{
                //成绩开始时间
                NSArray *cjArr1 = [_endTime componentsSeparatedByString:@"-"];
                //月份
                NSString *str = nil;
                if ([cjArr1[1] integerValue] < 10) {
                    str = [NSString stringWithFormat:@"0%@",cjArr1[1]];
                }else {
                    str = [NSString stringWithFormat:@"%@",cjArr1[1]];
                }
                //日
                NSString *str1 = nil;
                if ([cjArr1[2] integerValue] < 10) {
                    str1 = [NSString stringWithFormat:@"0%@",cjArr1[2]];
                }else {
                    str1 = [NSString stringWithFormat:@"%@",cjArr1[2]];
                }
                NSString *sjTimer = [NSString stringWithFormat:@"%@-%@-%@",cjArr1[0],str,str1];
                [endButton setTitle:sjTimer forState:UIControlStateNormal];
                endButton.backgroundColor = [UIColor colorFromHexCode:@"#ffe0cb"];
                [endButton setTitleColor:[UIColor colorFromHexCode:@"#ff6b09"] forState:UIControlStateNormal];
                [endButton.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];
            }
        }else{
            endButton.tag = 2001;
            if (_monthEndTime == nil) {
                [endButton setTitle:@"(结束时间)" forState:UIControlStateNormal];
            }else{
                //月指标开始时间
                NSArray *cjArr1 = [_monthEndTime componentsSeparatedByString:@"-"];
                //月份
                NSString *str = nil;
                if ([cjArr1[1] integerValue] < 10) {
                    str = [NSString stringWithFormat:@"0%@",cjArr1[1]];
                }else {
                    str = [NSString stringWithFormat:@"%@",cjArr1[1]];
                }
                NSString *yzbTimer = [NSString stringWithFormat:@"%@-%@",cjArr1[0],str];
                [endButton setTitle:yzbTimer forState:UIControlStateNormal];
                endButton.backgroundColor = [UIColor colorFromHexCode:@"#ffe0cb"];
                [endButton setTitleColor:[UIColor colorFromHexCode:@"#ff6b09"] forState:UIControlStateNormal];
                [endButton.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];

            }
        }
        [cell addSubview:endButton];
        [endButton addTarget:self action:@selector(endButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
    //成绩或者月指标
    UILabel *shijianLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
    shijianLabel.text = @"年指标";
   
    UIButton *nianButton = [UIButton buttonWithType:UIButtonTypeCustom];
    nianButton.frame = CGRectMake(10, 40, SC_WIDTH - 20, 30);
    [nianButton setTitle:_yearStr forState:UIControlStateNormal];
    nianButton.titleLabel.font = [UIFont systemFontOfSize:15];
    nianButton.backgroundColor = [UIColor colorFromHexCode:@"#ffe0cb"];
    [nianButton setTitleColor:[UIColor colorFromHexCode:@"#ff6b09"] forState:UIControlStateNormal];
    [nianButton addTarget:self action:@selector(nianButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [cell addSubview:nianButton];
    [nianButton.layer setBorderColor:[UIColor colorFromHexCode:@"#FE6C07"].CGColor];
    [nianButton.layer setBorderWidth:0.5];
    nianButton.layer.cornerRadius = 3.0;
    [nianButton.layer setMasksToBounds:YES];
    
    shijianLabel.font = [UIFont systemFontOfSize:15];
    [cell addSubview:shijianLabel];
    return cell;
}
//所有时间按钮事件
- (void)allBUttonAction:(UIButton *)sender{
    if (sender.tag < 200) {//第一区时间按钮tag
        _timeIndex = sender.tag - 100;
        _beginTime = nil;
        _endTime = nil;
    }else{    //第二区时间按钮
        _indexIndex = sender.tag - 200;
        _monthBeginTime = nil;
        _monthEndTime = nil;
    }
    [_baseTable reloadData];
}
//起始时间按钮事件
- (void)beginButtonAction:(UIButton *)sender{
    if (sender.tag == 1000) {
        _dateTimePickerView = [[HcdDateTimePickerView alloc] initWithDatePickerMode:DatePickerDateMode defaultDateTime:[NSDate date]];
    }else{
        _dateTimePickerView = [[HcdDateTimePickerView alloc] initWithDatePickerMode:DatePickerYearMonthMode defaultDateTime:[NSDate date]];
    }
    _dateTimePickerView.frame = CGRectMake(0, -SafeAreaTopHeight, SC_WIDTH, SC_HEIGHT);
    [self addSubview:_dateTimePickerView];
    __weak ChooseView *weak = self;
    _dateTimePickerView.clickedOkBtn = ^(NSString * datetimeStr){
        NSLog(@"选择的时间是%@", datetimeStr);
        if (sender.tag == 1000) {
            weak.beginTime = datetimeStr;
            if (weak.endTime != nil) {
                _timeIndex = -1;
            }
        }else{
            weak.monthBeginTime = datetimeStr;
            if (weak.monthEndTime != nil) {
                _indexIndex = -1;
            }
        }
        [weak.baseTable reloadData];
    };
    [_dateTimePickerView showHcdDateTimePicker];
    
}
//结束时间按钮事件
- (void)endButtonAction:(UIButton *)sender{
    if (sender.tag == 1001) {
       _dateTimePickerView = [[HcdDateTimePickerView alloc] initWithDatePickerMode:DatePickerDateMode defaultDateTime:[NSDate date]];
    }else{
        _dateTimePickerView = [[HcdDateTimePickerView alloc] initWithDatePickerMode:DatePickerYearMonthMode defaultDateTime:[NSDate date]];
    }
    _dateTimePickerView.frame = CGRectMake(0, -SafeAreaTopHeight, SC_WIDTH, SC_HEIGHT);
    __weak ChooseView *weak = self;
    [self addSubview:_dateTimePickerView];
    _dateTimePickerView.clickedOkBtn = ^(NSString * datetimeStr){
        NSLog(@"选择的时间是%@", datetimeStr);
        if (sender.tag == 1001) {
            weak.endTime = datetimeStr;
            if (weak.beginTime != nil) {
                _timeIndex = -1;
            }
        }else{
            weak.monthEndTime = datetimeStr;
            if (weak.monthBeginTime != nil) {
                _indexIndex = -1;
            }
        }
        [weak.baseTable reloadData];
    };
    [_dateTimePickerView showHcdDateTimePicker];
}

//年限选择
- (void)nianButtonAction:(UIButton *)sender{
    _dateTimePickerView = [[HcdDateTimePickerView alloc] initWithDatePickerMode:DatePickerDateHourMinuteMode defaultDateTime:[NSDate date]];
    _dateTimePickerView.frame = CGRectMake(0, -SafeAreaTopHeight, SC_WIDTH, SC_HEIGHT);
    __weak ChooseView *weak = self;
    [self addSubview:_dateTimePickerView];
    _dateTimePickerView.clickedOkBtn = ^(NSString * datetimeStr){
        NSLog(@"选择的时间是%@", datetimeStr);
        _yearStr = datetimeStr;
        [weak.baseTable reloadData];
        
    };
    [_dateTimePickerView showHcdDateTimePicker];
}

//重置按钮
- (void)resetButtonAction:(UIButton *)sender{
//    _timeIndex = [[_oldDic objectForKey:@"timeIndex"] intValue];
//    _indexIndex = [[_oldDic objectForKey:@"indexIndex"] intValue];;
//    _beginTime = [_oldDic objectForKey:@"beginTime"];
//    _endTime = [_oldDic objectForKey:@"endTime"];
//    _monthBeginTime = [_oldDic objectForKey:@"monthBeginTime"];
//    _monthEndTime = [_oldDic objectForKey:@"monthEndTime"];
//    _yearStr = [_oldDic objectForKey:@"yearStr"];
    _isfalg = YES;
    if (_chooseViewBlock) {
        _chooseViewBlock(@"1");
    }
    _timeIndex = 0;
    _indexIndex = 0;
    _beginTime = nil;
    _endTime = nil;
    _monthBeginTime = nil;
    _monthEndTime = nil;
    
    //默认当前年时间
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; //初始化格式器。
    [formatter setDateFormat:@"YYYY"];//定义时间为这种格式 YYYY-MM-dd hh:mm:ss 。
    NSString *currentTime = [formatter stringFromDate:[NSDate date]];
    _yearStr = currentTime;
    [_baseTable reloadData];
    
}
//确定按钮
- (void)sureButtonAction:(UIButton *)sender{
    if (_chooseViewBlock) {
        _chooseViewBlock(@"2");
    }
    _isfalg = NO;
    _chooseBlock( _timeIndex, _beginTime, _endTime, _indexIndex, _monthBeginTime, _monthEndTime ,_yearStr, nil);//0为确定
    [self removeFromSuperview];
}
//点击空白
- (void)removeHCD{
    if (_isfalg == YES) {
        _chooseBlock( _timeIndex, _beginTime, _endTime, _indexIndex, _monthBeginTime, _monthEndTime ,_yearStr, @"1");//1为点击空白
    }
    if (_chooseViewBlock) {
        _chooseViewBlock(@"2");
    }
    
    [_dateTimePickerView removeFromSuperview];
    [self removeFromSuperview];
}

@end
